include ../Makefile.inc

SUB_MODULES = $(OBJ_DIR)/webcmd.o $(OBJ_DIR)/http_control.o $(OBJ_DIR)/indexed_log.o
SUB_HEADERS = webcmd.h http_control.h indexed_log.h

$(BIN_DIR)/minecraft_proxy : $(OBJ_DIR)/main.o $(SUB_MODULES) $(OBJ_DIR)/index_html.o $(OBJ_DIR)/jquery_js.o
	$(CXX) $^ $(LIBS) -o $@
	-sudo chown root $(BIN_DIR)/minecraft_proxy
	-sudo chmod u+s $(BIN_DIR)/minecraft_proxy

$(OBJ_DIR)/index_html.o : html/index.html
	objcopy --input binary --output elf64-x86-64 --binary-architecture i386  html/index.html $(OBJ_DIR)/index_html.o 

$(OBJ_DIR)/jquery_js.o : html/jquery.js
	objcopy --input binary --output elf64-x86-64 --binary-architecture i386 html/jquery.js $(OBJ_DIR)/jquery_js.o 

$(OBJ_DIR)/main.o : main.cpp $(SUB_HEADERS) constants.h $(TOOLS_LIB_FILE)
	-mkdir -p $(OBJ_DIR)
	$(CXX) $(INCLUDES) $< -c -o $@
	
$(OBJ_DIR)/%.o : %.cpp %.h constants.h $(TOOLS_LIB_FILE)
	-mkdir -p $(OBJ_DIR)
	$(CXX) $(INCLUDES) $< -c -o $@

$(TOOLS_LIB_FILE) : force_look
	cd ..; $(MAKE) lib

clean:
	rm -f $(OBJ_DIR)/*
	rm -f $(BIN_DIR)/minecraft_proxy

force_look:
	true
